package br.com.emanuelvictor.architectureandroid.app1.entity;

import java.text.SimpleDateFormat;
import java.util.Calendar;

import android.annotation.SuppressLint;
import android.content.ContentValues;
import android.util.Log;

@SuppressLint("SimpleDateFormat")
public class Point {
	
	public Long id;
	public Calendar date;

	public Point() {
		this.date = Calendar.getInstance();
	}

	public Point(Calendar date) {
		this.date = date;
	}

	public Point(Long id, String date) {
		this.id = id;
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		this.date = Calendar.getInstance();
		try {
			this.date.setTime(df.parse(date));
		} catch (Exception e) {

		}
	}

	public ContentValues toContentValues() {

		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

		ContentValues contentValues = new ContentValues();
		try {
			Log.d("", df.format(this.date.getTime()));
			contentValues.put("date", df.format(this.date.getTime()));
		} catch (Exception e) {
			Log.d("", df.format(this.date.getTime()));
			Log.e("", "Erro ao parsear");
		}
		return contentValues;
	}
	
	@Override
	public String toString() {
			return "Point [id=" + id + ", date=" + date + "]";
	}
	
	public String getSringDate() {
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		String date = df.format(this.date.getTime());
//		Log.i("StringDate",date);
		return date;
		
	}


}